<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

use App\Models\Admin\Share;

class ShareController extends Controller
{
    // 初始化 分享经济信息
    public function iniShare(Request $request)
    {
        // 获取分享经济信息 => 验证 -> 获取
        $Share = new Share;
        $getShare = $Share->analyShare($request['id'] ? $request['id'] : 0);
        return $getShare;
    }

    // 根据前台返回内容 , 整理前台所需比例内容
    public function inputRadio(Request $request)
    {
        $shareInfo = [];
        $Share = new Share;
        $shareInfo['store_id'] = $request['store_id'];
        $shareInfo['type'] = $request['type'];
        $shareInfo['num'] = $request['num'];
        $shareInfo['method'] = $request['method'];
        $shareInfo['inputRadio'] = $Share->inputRadio($shareInfo, 1);
        return self::successClient($shareInfo);
    }

    // 提交分享经济信息
    public function shareSubmit(Request $request)
    {
        // 验证字段合法性 => 提交数据
        $Share = new Share;
        $insertShare = $Share->insertAnlayArr($request['id'], $request['data']);
        return $insertShare;
    }
}
